package com.lww.feature.test.array;

import org.joda.time.DateTime;
import org.junit.Test;

import javax.sound.midi.Soundbank;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author yi an
 * @date 2017/3/30
 */
public class test {

    @Test
    public void initTest() {
        String[] strArr = new String[10];
        if (null == strArr[0]) {
            System.out.println("============================");
        }
        System.out.println(strArr[0]);

    }
    @Test
    public void initTest2() {
        String[] strArr = new String[10];
        String a = strArr[0];
        a = "999";
        strArr[0] = a;
        System.out.println(a);
        System.out.println(strArr[0]);
    }
    @Test
    public void byteArrayInt() {
        byte[] bytes = new byte[10];
        for (int i =0;i<10;i++) {
            System.out.println(bytes[i]);
        }
        bytes[0] = 7;
        bytes[1]=8;
        System.out.println("================");
        for (int i =0;i<10;i++) {
            System.out.println(bytes[i]);
        }
    }

    public static void main(String[] args) {

        DateTime today1 = new DateTime();

        DateTime dateTime = today1.minusDays(30);

        System.out.println(dateTime);
        List<Date> days = new ArrayList<>();

        setDaysNeedStatistics(days,today1,dateTime);
        System.out.println(days);

        List<Date> months = new ArrayList<>();


        setMonthsNeedStatistics(today1,dateTime,months);
        System.out.println(months);

    }


    private static void setDaysNeedStatistics(List<Date> daysNeedStatic,
                                       DateTime syncAttendanceEndDateTime, DateTime syncAttendanceStartDateTime) {
        DateTime cursor = syncAttendanceEndDateTime;
        while (!cursor.toString("yyyy-MM-dd")
                .equals(syncAttendanceStartDateTime.toString("yyyy-MM-dd"))) {
            daysNeedStatic.add(cursor.toDate());
            cursor = cursor.minusDays(1);
        }
        daysNeedStatic.add(syncAttendanceStartDateTime.toDate());
    }


    private static void setMonthsNeedStatistics(DateTime syncAttendanceEndDateTime,
                                         DateTime syncAttendanceStartDateTime, List<Date> monthsNeedStatistics) {
        monthsNeedStatistics.add(syncAttendanceEndDateTime.toDate());
        if (!syncAttendanceEndDateTime.monthOfYear()
                .equals(syncAttendanceStartDateTime.monthOfYear())) {
            monthsNeedStatistics.add(syncAttendanceStartDateTime.toDate());
        }
    }
}
